package com.cskt.petproject178.service.impl;

import com.cskt.petproject178.mapper.ReceiverAddressMapper;
import com.cskt.petproject178.pojo.entity.ReceiverAddress;
import com.cskt.petproject178.service.AddressService;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author 27013
 **/

@Service
public class AddressServiceImpl implements AddressService {
    @Resource
    private ReceiverAddressMapper receiverAddressMapper;

    @Override
    public boolean insertSelective(ReceiverAddress record) {
        if (record.getDefaultStatus()==1){
            receiverAddressMapper.updateDefaultAddress(record.getUserId());
        }
        return receiverAddressMapper.insertSelective(record) > 0;
    }

    @Override
    public boolean updateByPrimaryKeySelective(ReceiverAddress record) {
        if (record.getDefaultStatus()==1){
            receiverAddressMapper.updateDefaultAddress(record.getUserId());
        }
        return receiverAddressMapper.updateByPrimaryKeySelective(record) > 0;
    }
}
